/*
* @Author: Marte
* @Date:   2017-08-02 18:20:52
* @Last Modified by:   Marte
* @Last Modified time: 2017-08-04 14:23:18
*/


var ds_url="http://openapi.roewe.com.cn";
var MAP;
var marks = [];
var _data;
$(function(){
    get_province('10000000000019');
    get_city('10000000000019', '10000000000335');

    function get_province(nodeid) {
    var content = container = '';
    var url = ds_url + "/ndms-base-server/getArea/2/1000000000/1/2";
    $.getJSON(url + '?callback=?', function(data) {
      if (data) {
          level = 1;
          content = '';
          $.each(data, function(i, data) {
              if (nodeid == data.id) {
                  content += '<option selected value="' + data.id + '\" alert=' + data.name + '>' + data.name + '</option>';
              } else {
                  content += '<option value="' + data.id + '\"  alert=' + data.name + '>' + data.name + '</option>';
              }

          })
          $("#province").show();
          $("#province").html(content);
          $("#province").live("change", function() {
              var province = $(this).val()
              var provinces = $(this).find("option:selected").attr("alert");
              $(".dealer-list-title").html(provinces);
              if (province != '') {
                  get_city(province);
                  //dealer(province);
                  //dealer_province(province);
                  return;
              }
          });
      } else {

      }
  })
}

//我在这里修改了内容

function get_city(nodeid, cityid) {
    var content = container = '';
    $("#jxs").html(content);
    var url = ds_url + "/ndms-base-server/getArea/3/" + nodeid + "/1/2";
    $.getJSON(url + '?callback=?', function(data) {
        if (data) {
            level = 1;
            content += '<option value="-1">请选择城市</option>';
            $.each(data, function(i, data) {
                if (cityid == data.id) {
                    content += '<option selected value="' + data.id + '\">' + data.name + '</option>';
                } else {
                    content += '<option value="' + data.id + '\" >' + data.name + '</option>';
                }
            })
            $("#city").show();
            $("#city").html(content);
        } else {
            content = '<option value="-1">请选择城市</option>';
            $("#city").html(content);
        }
    })
}
})
